#ifndef SCANAPI_H
#define SCANAPI_H

/*
 * 文件扫描接口api封装，当前采用远程模式
 */

#include <QString>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QEventLoop>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QBuffer>


namespace ScanRemoteApi {
    const static QString BASE_URL = "http://127.0.0.1:32000";

    // 远端基础路径查询
    const static QString QUERY_SCAN_PATH = BASE_URL + "/get/scan/";
    // 远端缓存查询
    const static QString QUERY_CACHE = BASE_URL + "/get/cache/";
    // 远端缓存消耗
    const static QString CONSUME_CACHE = BASE_URL + "/put/consume/";


    extern QString scanPath;
}

namespace ScanApiResult {
    typedef struct ApiResult{
        int code;  // 请求状态码
        QString errMsg;  // 请求错误信息
    }RemoteScanApiResult;

    typedef struct ApiCacheResult : RemoteScanApiResult {
        QString fileName;  // cache文件名
        int id;  // 文件id
    }RemoteScanApiCacheResult;
}

namespace SyncScanApi{
    ScanApiResult::RemoteScanApiResult initScanPath();
    ScanApiResult::RemoteScanApiCacheResult getNextCache();
    ScanApiResult::RemoteScanApiResult consumeFileCache(int id);
}



#endif // SCANAPI_H
